'use strict';
import loginInterceptor from "../../common/util/loginInterceptor";
export default class extends think.controller.base {

  /**
   * some base method in here
   */
  async __before(){
    this.header("Access-Control-Allow-Origin", "http://127.0.0.1:8360");
    this.header("Access-Control-Allow-Headers", "x-requested-with");
    this.header("Access-Control-Request-Method", "GET,POST,PUT,DELETE");
    let flag=loginInterceptor("/"+this.http.module+"/"+this.http.controller+"/"+this.http.action);
    if(flag){
      let username = await this.session("username");
      //如果没有登录，则跳转到登录页面
      if(think.isEmpty(username)){
        return this.fail(401,"请选登录");
      }
    }
  }
}